<?php


namespace App\Libraries\CustomsBills\Data;


use App\Libraries\CustomsBills\Assert;

class BaseTransfer
{
    protected $copCode;
    protected $copName;
    protected $dxpMode = 'DXP';
    protected $dxpId;

    /**
     * @return mixed
     * @author luffyzhao@vip.126.com
     */
    public function getCopCode()
    {
        Assert::length($this->copCode, 10, "报文传输企业代码 固定长度10个字符");
        return $this->copCode;
    }

    /**
     * @param mixed $copCode
     * @author luffyzhao@vip.126.com
     */
    public function setCopCode($copCode): void
    {
        $this->copCode = $copCode;
    }

    /**
     * @return mixed
     * @author luffyzhao@vip.126.com
     */
    public function getCopName()
    {
        Assert::notEmpty($this->copName, '报文传输企业名称 必须填写');
        Assert::maxLength($this->copName, 100, "报文传输企业名称 固定长度100个字符");
        return $this->copName;
    }

    /**
     * @param mixed $copName
     * @author luffyzhao@vip.126.com
     */
    public function setCopName($copName): void
    {
        $this->copName = $copName;
    }

    /**
     * @return mixed
     * @author luffyzhao@vip.126.com
     */
    public function getDxpMode()
    {
        return $this->dxpMode;
    }

    /**
     * @param mixed $dxpMode
     * @author luffyzhao@vip.126.com
     */
    public function setDxpMode($dxpMode): void
    {
        $this->dxpMode = $dxpMode;
    }

    /**
     * @return mixed
     * @author luffyzhao@vip.126.com
     */
    public function getDxpId()
    {
        Assert::notEmpty($this->dxpId, "报文传输编号 不能为空");
        Assert::maxLength($this->dxpId, 30, "报文传输编号 最大长度30个字符");
        return $this->dxpId;
    }

    /**
     * @param mixed $dxpId
     * @author luffyzhao@vip.126.com
     */
    public function setDxpId($dxpId): void
    {
        $this->dxpId = $dxpId;
    }

    /**
     * @return string
     * @author luffyzhao@vip.126.com
     */
    public function __toString(): string
    {
        return <<<BaseTransfer
<ceb:BaseTransfer>
    <ceb:copCode>{$this->getCopCode()}</ceb:copCode>
    <ceb:copName>{$this->getCopName()}</ceb:copName>
    <ceb:dxpMode>{$this->getDxpMode()}</ceb:dxpMode>
    <ceb:dxpId>{$this->getDxpId()}</ceb:dxpId>
</ceb:BaseTransfer>
BaseTransfer;
    }

}